#include<vector>
using namespace std;
class Solution {
public:
    int search(vector<int>& nums, int target) {
        int left = 0;
        int right = nums.size()-1;
        while (left<=right && nums[left]<target)
        {
            left++;
        }
        while (left<=right && nums[right]>target)
        {
            right--;
        }
        return right-left+1;
    }
};